package com.gc.server.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import java.util.Map;
import com.yf.consts.DaoConst;
import com.gc.server.entity.GoodsRecordEntity;
import com.gc.server.service.GoodsRecordService;
import com.yf.response.R;


/**
 * 业务员物料消费Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Tue Mar 10 11:17:45 CST 2020
 */
@RestController
@RequestMapping("/goods/record")
public class GoodsRecordController {
    @Autowired
    private GoodsRecordService goodsRecordService;

    /**
     * 列表业务员物料消费
     */
    @RequestMapping("/list")
    @RequiresPermissions("goods:record:list")
    public R list(@RequestParam Map<String,Object> params) {
        PageHelper.startPage(DaoConst.getPage(params),DaoConst.getLIMIT(params));
        List<GoodsRecordEntity> goodsRecordList = goodsRecordService.queryList(params);
        return R.ok(new PageInfo(goodsRecordList));
    }

    /**
     * 查看业务员物料消费
     */
    @SysLog("查看业务员物料消费")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("goods:record:info")
    public R info(@PathVariable("id") Long id) {
        GoodsRecordEntity goodsRecord = goodsRecordService.get(id);

        return R.ok(goodsRecord);
    }

    /**
     * 保存业务员物料消费
     */
    @SysLog("保存业务员物料消费")
    @RequestMapping("/save")
    @RequiresPermissions("goods:record:save")
    public R save(GoodsRecordEntity goodsRecord) {
        goodsRecordService.save(goodsRecord);

        return R.ok(goodsRecord);
    }

    /**
     * 修改业务员物料消费
     */
    @SysLog("修改业务员物料消费")
    @RequestMapping("/update")
    @RequiresPermissions("goods:record:update")
    public R update(GoodsRecordEntity goodsRecord) {
        goodsRecordService.update(goodsRecord);

        return R.ok(goodsRecord);
    }

    /**
     * 删除业务员物料消费
     */
    @SysLog("删除业务员物料消费")
    @RequestMapping("/delete")
    @RequiresPermissions("goods:record:delete")
    public R delete(Long[]ids) {
        goodsRecordService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有业务员物料消费
     */
    @SysLog("所有业务员物料消费")
    @RequestMapping("/queryAll")
    public R queryAll (@RequestParam Map<String,Object> params) {

        List<GoodsRecordEntity> goodsRecordList = goodsRecordService.queryList(params);

        return R.ok(goodsRecordList);
    }

    /**
    @ModelAttribute
    public SearchParam<GoodsRecordEntity> searchParam(SearchParam<GoodsRecordEntity> params, GoodsRecordEntity goodsRecord) {
        if (goodsRecord != null) {
            params.setEntity(goodsRecord);
        }

        return params;
    }
 **/
    /***********自定义开始***********/
}
